package com.leen.user.controller;



import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.user.dto.YxUserDTO;
import com.leen.user.entity.YxUser;
import com.leen.user.service.YxUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户表API
 */
@RestController
@Api(tags = "用户表API")
@RequestMapping(value ="/yxuser")
public class YxUserController {

    @Autowired
    private YxUserService yxUserService;

    @ApiOperation(value = "分页查询数据")
    @GetMapping(value = "/yxuser/Pagedata")
    public ResultVO<ResponseVO>search(YxUserDTO yxUserDTO){
        return ResultVO.success(this.yxUserService.search(yxUserDTO));
    }

    @ApiOperation(value = "新增数据")
    @PostMapping(value = "/yxuser/add")
    public ResultVO<String> add(@RequestBody YxUser yxUser){
       YxUser save = this.yxUserService.save(yxUser);
        return  save!=null? ResultVO.success(ResultEnum.DB_SUCCESS): ResultVO.failed(ResultEnum.DB_FAILED);
    }

    @ApiOperation(value = "修改数据")
    @PostMapping(value = "/yxuser/update")
    public ResultVO<String> update(@RequestBody YxUser yxUser){
        YxUser update = this.yxUserService.save(yxUser);
        return update!=null?ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);

    }

}
